/**
 * 
 */
package neptune.web.client.view.components;

import neptune.web.client.commands.OpenUserDetailsCommand;

import org.gwtlib.client.table.Row;
import org.gwtlib.client.table.ui.Column;
import org.gwtlib.client.table.ui.renderer.Renderer;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author Roberto Bifulco [info@robertobifulco.it, robertobifulco.it]
 *
 */
public class UsernameTableRenderer implements Renderer {

	/* (non-Javadoc)
	 * @see org.gwtlib.client.table.ui.renderer.Renderer#render(org.gwtlib.client.table.Row, org.gwtlib.client.table.ui.Column, java.lang.Object)
	 */
	public Widget render(Row row, Column column, Object value) {
		Label label = new Label((String)value);
		label.setStyleName("UserSummaryView-username");
		label.addClickListener(new ClickListener() {
		
			public void onClick(Widget arg0) {
				Label lb = (Label)arg0;
				
				Command cmd = new OpenUserDetailsCommand(lb.getText());
		
				cmd.execute();
			}
		
		});
		return label;
	}

}
